using System;
using System.ComponentModel;
using System.Data;
using System.Collections.Generic;

namespace PlacementManager
{
    public partial class ContactAttributeComponent
    {
		//
		// TODO: Add constructor logic here
		//

        /// <summary>
        /// Selects all records from the database table.
        /// </summary>
        /// <returns>A collection of objects of a type representing a row in the database table.</returns>
        [DataObjectMethodAttribute(DataObjectMethodType.Select, true)]
        public List<ContactAttribute> SelectAllWDivisionId(int divisionId, string sortExpression)
        {
            List<ContactAttribute> listContactAttribute = new List<ContactAttribute>();
            PlacementManager.DAL.ContactAttribute_DAL o = new PlacementManager.DAL.ContactAttribute_DAL();

            o.DivisionId = divisionId;
            DataSet ds = o.SelectAllWDivisionId();

            foreach (DataRow row in ds.Tables[0].Rows)
            {
                listContactAttribute.Add(new ContactAttribute((int)row["ContactAttributeId"], (int)row["DivisionId"], (string)row["AttributeName"], (bool)row["IsActive"], (DateTime)row["DateCreated"], (string)row["CreatedBy"], (DateTime)row["DateUpdated"], (string)row["UpdatedBy"]));
            }

            if (sortExpression == string.Empty)
            {
                sortExpression = "DateCreated desc";
            }

            listContactAttribute.Sort(new ContactAttributeComparer(sortExpression));
            return listContactAttribute;
        }
	}
}
